<?
include('adodb/adodb-exceptions.inc.php'); 
require ("comun/ini.php");
if(isset($_POST['JsonEnv'])){
	$JsonRec = new Services_JSON();
	$JsonEnv = new Services_JSON();
	$JsonRec=$JsonRec->decode(str_replace("\\","",$_POST['JsonEnv']));
	try {
		$q = "SELECT round(montos_pagados,2) - round(deudas_pagar,2) AS saldo FROM saldos_peritos WHERE id_perito=$JsonRec->Perito AND round(montos_pagados,2) > round(deudas_pagar,2) LIMIT 1";
		//die($q);
		$r = $conn->Execute($q);
		$i=0;
		if(!$r->EOF){
			$Saldo[$i]['S'] = muestrafloat($r->fields['saldo']);
			$i++;
			$r->movenext();
		} else {
			$Saldo[$i]['S'] = 0;
		}

		if(is_array($Saldo)){
			echo $JsonEnv->encode($Saldo);
		}else{
			echo false;
		}
	}catch( ADODB_Exception $e ){
		//	echo ERROR_CATCH_GENERICO;
		echo false;
	}
} 
?>